#ifndef HAIKUOS_INCLUDE_POSIX_ARCH_X86_64_H
#define HAIKUOS_INCLUDE_POSIX_ARCH_X86_64_H

#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>

typedef struct
{
    struct
    {
        uint32_t __control;
        uint32_t __status;
        uint32_t __tag;
        char __other[16];

    } __x87;
    uint32_t __mxcsr;
} fenv_t; // float env ?

typedef uint16_t fexcept_t;

// exception flags
#define FE_INVALID 0x01   // invalid
#define FE_DENORMAL 0x02  // denormal
#define FE_DIVBYZERO 0x04 // div by zero
#define FE_OVERFLOW 0x08  // overflow
#define FE_UNDERFLOW 0x10 // underflow
#define FE_INEXACT 0x20   // inexact
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)

// rounding modes
#define FE_TONEAREST 0x0000
#define FE_DOWNWARD 0x0400
#define FE_UPWARD 0x0800
#define FE_TOWARDZERO 0x0c00
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)

// as compared to the x87 control word, the SSE unit's
// control word has the rounding control bits offset by 3
// and the exception mask bits offset by 7
#define _SSE_ROUND_SHIFT 3
#define _SSE_EMASK_SHIFT 7

__BEGIN_DECLS
// TODO:

__END_DECLS

#endif // header file protect